home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Pascal Super Library
/
Pascal Super Library (CW International)(1997).bin
/
BORL_TIP
/
TI1000
/
TI1725.ASC
< prev
next >
Wrap
Text File
|
1994-10-03
|
2KB
|
111 lines
PRODUCT : Pascal NUMBER : 1725
VERSION : All
OS : DOS
DATE : September 30, 1994 PAGE : 1/2
TITLE : Turbo Vision local menu using right mouse button
This is an example Turbo Vision program that demonstrates using
local menus that are activated with the right mouse button
and are positioned on screen by the mouse position.
program Localmenu;
uses
Drivers, Objects, Views, App, Menus;
const
cmNothing = 101;
type
TMyApp = object(TApplication)
LocalMenu: PMenu;
LocalMenuOpen: boolean;
constructor Init;
procedure GetEvent(var Event: TEvent); virtual;
end;
constructor TMyApp.Init;
begin
inherited Init;
LocalMenu := NewMenu(
NewItem('Item~1~', '', 0, cmNothing, hcNOContext,
NewItem('Item~2~', '', 0, cmNothing, hcNoContext,
nil)));
LocalMenuOpen := false;
EventMask := EventMask or evBroadcast;
end;
procedure TMyApp.GetEvent(var Event: TEvent);
var
MousePt: TPoint;
R: TRect;
Box: PMenuBox;
NewEvent: TEvent;
Code: Word;
PRODUCT : Pascal NUMBER : 1725
VERSION : All
OS : DOS
DATE : September 30, 1994 PAGE : 2/2
TITLE : Turbo Vision local menu using right mouse button
begin
inherited GetEvent(Event);
if ((Event.What = evMouseDown) AND (Event.Buttons =
mbRightButton) AND NOT LocalMenuOpen)
then
begin
LocalMenuOpen := true;
MousePt := Event.Where;
if (MousePt.X > 70) then MousePt.X := 70;
if (MousePt.Y > 20) then MousePt.Y := 20;
ClearEvent(Event);
R.Assign(MousePt.X, MousePt.Y, MousePt.X+11, MousePt.Y+2);
Box := new(PMenuBox, Init(R, LocalMenu, nil));
Code := ExecView(Box);
Dispose(Box);
LocalMenuOpen := false;
NewEvent.What := evBroadcast;
NewEvent.Command := code;
PutEvent(NewEvent);
end;
end;
var
MyApp: TMyApp;
begin
MyApp.Init;
MyApp.Run;
MyApp.Done;
end.
DISCLAIMER: You have the right to use this technical information
subject to the terms of the No-Nonsense License Statement that
you received with the Borland product to which this information
pertains.